package test;
import java.util.Map;

import cn.hutool.core.util.CharsetUtil;
import cn.hutool.core.util.StrUtil;
import cn.hutool.crypto.asymmetric.KeyType;
import cn.hutool.crypto.asymmetric.RSA;
import cn.hutool.http.HttpRequest;
import cn.hutool.json.JSONUtil;

public class testmain {
    public static void main(String[] args) {
        String APPID="d9ee3158-77b1-5276-a868-3e7552224cff";

        //String APPID = "EEAA5436-7577-4BE0-8C6C-89E9D44801EA";

        String secret ="67bcb3d8-66e7-43fc-bab2-2d0cde02f103";
        String spk = "MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCYpQ+hhHZ3BtFO82eT9ws4gIxHI25O4jUoH6SEnzNS3P/LK5KkbxgurlmlvwWqnHiMPP2e+piV+5d69MBXS5v3nzomFq1yvLaAowB3uenSHKhrDJYju44EqTc585T4mQ1GfeNbzKe0vNea6N+vH2PoHAnwK47stYZ/Xt8Bbj2NGQIDAQAB";
        //ECOLOGY 返回的系统密钥
        RSA rsa = new RSA(null,spk);
        //对秘钥进行加密传输，防止篡改数据
        String encryptSecret = rsa.encryptBase64(secret,CharsetUtil.CHARSET_UTF_8,KeyType.PublicKey);
        //调用 ECOLOGY 系统接口进行注册
        String data = HttpRequest.post("http://oa.maxwell-gp.com.cn:8090"+ "/api/ec/dev/auth/applytoken")
                .header("appid",APPID)
                .header("secret",encryptSecret)
                .header("time","3600")
                .execute().body();
        System.out.println("testGetoken()："+data);
        Map<String,Object> datas = JSONUtil.parseObj(data);

    }
}
